<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const obj={
            id:100001,
            name:`Bit`,
            age:9,
            address:`陕西省西安市高新区`
        }
        //以前：使用for-in遍历对象
        // for(let key in obj)
        // {
        //     console.log(key,obj[key])
        // }

        //现在的：Object.keys()+forEach
        // Object.keys(obj).forEach((key)=>{
        //     console.log(key,obj[key])
        // })

        //只遍历obj中以a为开头的属性
        Object.keys(obj).filter((key)=> key.startsWith('a')).forEach((key)=> { console.log(key,obj[key])})

    </script>
</body>
</html>